package com.iwhalecloud.bss.kite.cucc.service.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.google.common.collect.Lists;
import com.iwhalecloud.bss.kite.common.constant.SymbolConsts;
import com.iwhalecloud.bss.kite.common.util.KiteListUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.api.attr.IUnicomRegionService;
import com.iwhalecloud.bss.kite.cucc.client.dto.attr.UnicomRegion;
import com.iwhalecloud.bss.kite.cucc.client.dto.attr.UnicomRegionQry;
import com.iwhalecloud.bss.kite.cucc.client.dto.batch.MergedResult;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import com.iwhalecloud.bss.kite.dataservice.entity.spec.ProdAttr;
import com.ztesoft.bss.common.util.SpringUtil;

/**
 * Excel操作工具类
 */
public final class ExcelUtil {

    private static final SimpleDateFormat DF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private ExcelUtil() {
    }

    /**
     * 读取Excel 文件中内容
     *
     * @param inputStream
     * @param initialRow 从第几行开始解析（0-based）
     * @param isXls 是否xls格式
     * @return
     * @throws IOException
     */
    public static List<List<String>> getExcelData(InputStream inputStream, int initialRow, boolean isXls)
        throws IOException {
        return getExcelData(inputStream, initialRow, isXls, DF);
    }

    public static List<List<String>> getExcelData(InputStream inputStream, int initialRow, boolean isXls,
                                                  DateFormat dateFormat) throws IOException {
        List<List<String>> squareList = new ArrayList<List<String>>();
        Workbook workbook = null;
        if (isXls) {
            workbook = new HSSFWorkbook(inputStream); // 解析xls格式
        }
        else {
            workbook = new XSSFWorkbook(inputStream); // 解析xlsx格式
        }
        // 在Excel文档中，第一张工作表的缺省索引是0
        Sheet sheet = workbook.getSheetAt(0);
        // 循环行Row
        for (int rowIndex = initialRow, maxRowIndex = sheet.getLastRowNum(); rowIndex <= maxRowIndex; rowIndex++) {
            Row row = sheet.getRow(rowIndex);
            if (row == null) {
                continue;
            }
            // 存放每行信息
            List<String> li = new ArrayList<String>();
            // 循环列
            for (int i = 0; i< row.getLastCellNum(); i++ ) {
                Cell cell = row.getCell(i);
                if (cell == null) {
                    li.add("");
                    continue;
                }
                switch (cell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        li.add(cell.getRichStringCellValue().getString());
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        if (DateUtil.isCellDateFormatted(cell)) {
                            li.add(dateFormat.format(cell.getDateCellValue()));
                        }
                        else {
                            cell.setCellType(Cell.CELL_TYPE_STRING);
                            String s = cell.getStringCellValue();
                            if (s.indexOf('.') > -1) {
                                li.add(String.valueOf(new Double(s)));
                            }
                            else {
                                li.add(s.trim());
                            }
                        }
                        break;
                    case Cell.CELL_TYPE_BOOLEAN:
                        li.add(String.valueOf(cell.getBooleanCellValue()));
                        break;
                    default:
                        li.add(null);
                        break;
                }
            }
            squareList.add(li);
        }
        return squareList;
    }

    public static List<Map<String, Object>> getExcelData(InputStream inputStream, int initialRow, boolean isXls,
                                                         String[] colName) throws IOException {
        List<Map<String, Object>> squareList = new ArrayList<Map<String, Object>>();
        Workbook workbook = null;
        if (isXls) {
            workbook = new HSSFWorkbook(inputStream); // 解析xls格式
        }
        else {
            workbook = new XSSFWorkbook(inputStream); // 解析xlsx格式
        }
        // 在Excel文档中，第一张工作表的缺省索引是0
        Sheet sheet = workbook.getSheetAt(0);
        Row firstRow = sheet.getRow(0); //第一行
        Map<String, Object> errmap = new HashMap<String, Object>();
        if ((colName.length - 1) != firstRow.getLastCellNum()) { //如果第一行没有3列，则导入文件格式不对
            errmap.put("errMsg", "请检查，导入模板格式不对应！");
            squareList.add(errmap);
            return squareList;
        }
        String key = "";
        // 循环行Row
        for (int rowIndex = initialRow, maxRowIndex = sheet.getLastRowNum(); rowIndex <= maxRowIndex; rowIndex++) {
            Row row = sheet.getRow(rowIndex);
            if (row == null) {
                continue;
            }
            // 存放每行信息
            Map<String, Object> mapCol = new HashMap<String, Object>();
            mapCol.put(colName[0], rowIndex + 1); //存入行数
            for (int i = 0; i < row.getLastCellNum(); i++) {
                key = colName[i + 1]; // 定义的列名
                Cell cell = row.getCell(i);
                if (cell == null) {
                    mapCol.put(key, "");
                    continue;
                }
                switch (cell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        mapCol.put(key, cell.getRichStringCellValue().getString());
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        if (DateUtil.isCellDateFormatted(cell)) {
                            mapCol.put(key, DF.format(cell.getDateCellValue()));
                        }
                        else {
                            cell.setCellType(Cell.CELL_TYPE_STRING);
                            String s = cell.getStringCellValue();
                            if (s.indexOf('.') > -1) {
                                mapCol.put(key, String.valueOf(new Double(s)));
                            }
                            else {
                                mapCol.put(key, s.trim());
                            }
                        }
                        break;
                    case Cell.CELL_TYPE_BOOLEAN:
                        mapCol.put(key, String.valueOf(cell.getBooleanCellValue()));
                        break;
                    default:
                        mapCol.put(key, "");
                        break;
                }
            }
            squareList.add(mapCol);
        }
        return squareList;
    }

    public static List<Map<String, Object>> getExcelDataAgree(InputStream inputStream, int initialRow, boolean isXls,
                                                              String[] colName) throws IOException {
        List<Map<String, Object>> squareList = new ArrayList<Map<String, Object>>();
        Workbook workbook = null;
        if (isXls) {
            workbook = new HSSFWorkbook(inputStream); // 解析xls格式
        }
        else {
            workbook = new XSSFWorkbook(inputStream); // 解析xlsx格式
        }
        // 在Excel文档中，第一张工作表的缺省索引是0
        Sheet sheet = workbook.getSheetAt(0);
        String key = "";
        // 循环行Row
        for (int rowIndex = initialRow, maxRowIndex = sheet.getLastRowNum(); rowIndex <= maxRowIndex; rowIndex++) {
            Row row = sheet.getRow(rowIndex);
            if (row == null) {
                continue;
            }
            // 存放每行信息
            Map<String, Object> mapCol = new HashMap<String, Object>();
            mapCol.put(colName[0], rowIndex + 1); //存入行数
            for (int i = 0; i < row.getLastCellNum(); i++) {
                key = colName[0]; // 定义的列名
                Cell cell = row.getCell(i);
                if (cell == null) {
                    mapCol.put(key, "");
                    continue;
                }
                switch (cell.getCellType()) {
                    case Cell.CELL_TYPE_STRING:
                        mapCol.put(key, cell.getRichStringCellValue().getString());
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        if (DateUtil.isCellDateFormatted(cell)) {
                            mapCol.put(key, DF.format(cell.getDateCellValue()));
                        }
                        else {
                            cell.setCellType(Cell.CELL_TYPE_STRING);
                            String s = cell.getStringCellValue();
                            if (s.indexOf('.') > -1) {
                                mapCol.put(key, String.valueOf(new Double(s)));
                            }
                            else {
                                mapCol.put(key, s.trim());
                            }
                        }
                        break;
                    case Cell.CELL_TYPE_BOOLEAN:
                        mapCol.put(key, String.valueOf(cell.getBooleanCellValue()));
                        break;
                    default:
                        mapCol.put(key, "");
                        break;
                }
            }
            squareList.add(mapCol);
        }
        return squareList;
    }

    /**
     * 导出Excel文档
     *
     * @throws FileNotFoundException
     */
    public static void exportExcelDocument(Map<String, Object> param, LinkedHashMap<String, String> titleMap,
                                           List<Map<String, Object>> result, OutputStream out) throws Exception {
        // 声明一个工作薄
        Workbook workbook = new HSSFWorkbook();
        // 生成一个表格
        Sheet sheet = workbook
            .createSheet(param == null || param.get("title") == null ? "未命名" : String.valueOf(param.get("title")));
        // 网格线
        sheet.setDisplayGridlines(true);
        // 设置默认表宽
        sheet.setDefaultColumnWidth(30);
        // 产生表格标题行
        Row row = sheet.createRow(0);
        // 生成一个样式
        CellStyle titleStyle = workbook.createCellStyle();
        // 设置这些样式
        titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
        titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        // 生成一个字体
        Font titleFont = workbook.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 12);
        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        // 把字体应用到当前的样式
        titleStyle.setFont(titleFont);
        int count = 0;
        for (String key : titleMap.keySet()) {
            Cell cell = row.createCell(count);
            cell.setCellStyle(titleStyle);
            cell.setCellValue(titleMap.get(key));
            count++;
        }
        for (int i = 0, iSize = result.size(); i < iSize; i++) {
            Map<String, Object> resultMap = result.get(i);
            // 生成一个字体
            Font contentFont = workbook.createFont();
            contentFont.setFontName("Arial");
            contentFont.setFontHeightInPoints((short) 10);
            contentFont.setBoldweight(Font.BOLDWEIGHT_NORMAL);
            // 生成一个样式
            CellStyle contentStyle = workbook.createCellStyle();
            contentStyle.setAlignment(CellStyle.ALIGN_CENTER);
            contentStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            row = sheet.createRow(i + 1);
            // 把字体添加到样式中去
            contentStyle.setFont(contentFont);
            count = 0;
            for (String key : titleMap.keySet()) {
                Cell cell = row.createCell(count);
                cell.setCellStyle(contentStyle);
                cell.setCellValue(String.valueOf(resultMap.get(key)));
                count++;
            }
        }
        workbook.write(out);
        out.flush();
        out.close();
    }

    /**
     * 判断单元格是否为日期
     *
     * @param cell
     * @return
     */
    public static boolean isCellDateFormatted(Cell cell) {
        if (cell == null) {
            return false;
        }
        boolean bDate = false;

        double d = cell.getNumericCellValue();
        if (isValidExcelDate(d)) {
            CellStyle style = cell.getCellStyle();
            if (style == null) {
                return false;
            }
            int i = style.getDataFormat();
            bDate = isInternalDateFormat(i);
        }
        return bDate;
    }

    public static boolean isValidExcelDate(Double value) {
        return (value > -4.940656458412465E-324D);
    }

    public static boolean isInternalDateFormat(int format) {
        boolean retval = false;
        switch (format) {
            case 14:
            case 15:
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 45:
            case 46:
            case 47:
                retval = true;
                break;
            case 23:
            case 24:
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
            case 33:
            case 34:
            case 35:
            case 36:
            case 37:
            case 38:
            case 39:
            case 40:
            case 41:
            case 42:
            case 43:
            case 44:
            default:
                retval = false;
        }
        return retval;
    }


    /**
     * 只适用于批量受理模版导出Excel文档（多行表头）
     *
     * @throws FileNotFoundException
     */
    public static void batchTempExportExcel(String name, List<String> titleListFirst, List<String> titleListSecond,
        List<MergedResult> titileMergeFirst, List<MergedResult> titileMergeSecond, OutputStream out, int aCol, int zCol, int cityCal,
        String provinceCode, Map<ProdAttr, Integer> attrIndex) throws Exception {
        // 声明一个工作薄
        Workbook workbook = new HSSFWorkbook();
        // 生成一个表格
        Sheet sheet = workbook.createSheet(KiteStringUtils.isEmpty(name) ? "未命名" : name);
        // 网格线
        sheet.setDisplayGridlines(true);
        // 设置默认表宽
        sheet.setDefaultColumnWidth(30);

        // 生成一个样式
        CellStyle titleStyle = workbook.createCellStyle();
        // 设置这些样式
        titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
        titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        titleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
        titleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); // 左边框
        titleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); // 上边框
        titleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); // 右边框
        // 生成一个字体
        Font titleFont = workbook.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short)12);
        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        // 把字体应用到当前的样式
        titleStyle.setFont(titleFont);
        int count = 0;
        // 产生表格标题第一行
        Row row = sheet.createRow(0);
        // 批量受理模版，按目前业务要求表头只有两行，先写死
        for (String title : titleListFirst) {
            Cell cell = row.createCell(count);
            cell.setCellStyle(titleStyle);
            cell.setCellValue(title);
            count++;
        }
        // 动态合并单元格
        for (MergedResult titileMerge : titileMergeFirst) {
            sheet.addMergedRegion(new CellRangeAddress(titileMerge.getFirstRow(), titileMerge.getLastRow(),
                titileMerge.getFirstColumn(), titileMerge.getLastColumn()));
        }

        // 产生表格标题第二行
        if (KiteListUtils.isNotEmpty(titileMergeSecond)) {
            Row rowSecond = sheet.createRow(1);
            count = titileMergeSecond.get(0).getFirstColumn();
            for (String title : titleListSecond) {
                Cell cell = rowSecond.createCell(count);
                cell.setCellStyle(titleStyle);
                cell.setCellValue(title);
                count++;
            }
            // 动态合并单元格
            for (MergedResult titileMerge : titileMergeSecond) {
                sheet.addMergedRegion(new CellRangeAddress(titileMerge.getFirstRow(), titileMerge.getLastRow(),
                    titileMerge.getFirstColumn(), titileMerge.getLastColumn()));
            }
        }

        // 设置省市区
        List<String> areaList = getAreaList(provinceCode);
        dropDownListArea(workbook, sheet, areaList.toArray(new String[] {}), 2, -1, aCol, zCol, cityCal, "hidden", 1);

        AtomicInteger i = new AtomicInteger(2);
        attrIndex.forEach((prodAttr, index) -> {
            List<AttrValue> attrValues = AttrValueCache.get(prodAttr.getAttrId());
            if (KiteListUtils.isEmpty(attrValues)) {
                return;
            }
            List<String> attrValueNames = attrValues.stream().map(AttrValue::getAttrValueName).collect(Collectors.toList());
            dropDownListAttrValue(workbook, sheet, attrValueNames.toArray(new String[] {}), 2, -1, index, "hidden" + i.get(),
                i.get());
            i.getAndIncrement();
        });

        workbook.write(out);
        out.flush();
        out.close();
    }

    private static List<String> getAreaList(String provinceCode) {
        List<String> resultList = new ArrayList<>();
        IUnicomRegionService unicomRegionService = SpringUtil.getBean(IUnicomRegionService.class);
        List<UnicomRegion> provinceList = unicomRegionService.subRegionFromPlatform(new UnicomRegionQry());
        UnicomRegion province = provinceList.stream()
            .filter(p -> KiteStringUtils.equals(p.getRegionCode(), provinceCode)).findFirst()
            .orElse(null);
        if (Objects.isNull(province)) {
            return Lists.newArrayList();
        }
        List<UnicomRegion> cityList = unicomRegionService.subRegionFromPlatform(new UnicomRegionQry(province.getRegionCode(), "20"));
        for (UnicomRegion city : cityList) {
            List<UnicomRegion> areaList = unicomRegionService.subRegionFromPlatform(new UnicomRegionQry(city.getRegionCode(), "30"));
            for (UnicomRegion area : areaList) {
                StringBuffer sb = new StringBuffer();
                sb.append(province.getRegionName()).append(SymbolConsts.SLASH).append(city.getRegionName())
                    .append(SymbolConsts.SLASH).append(area.getRegionName());
                resultList.add(sb.toString());
            }
        }
        return resultList;
    }

    /**
     * @param wb HSSFWorkbook对象
     * @param realSheet 需要操作的sheet对象
     * @param datas 下拉的列表数据
     * @param startRow 开始行
     * @param endRow 结束行
     * @param startCol 开始列
     * @param endCol 结束列
     * @param hiddenSheetName 隐藏的sheet名
     * @param hiddenSheetIndex 隐藏的sheet索引
     * @return
     */
    public static HSSFWorkbook dropDownListArea(Workbook wb, Sheet realSheet, String[] datas, int startRow, int endRow,
                                            int aCol, int zCol, int cityCal, String hiddenSheetName, int hiddenSheetIndex) {

        HSSFWorkbook workbook = (HSSFWorkbook) wb;
        // 创建一个数据源sheet
        HSSFSheet hidden = workbook.createSheet(hiddenSheetName);
        // 数据源sheet页不显示
        workbook.setSheetHidden(hiddenSheetIndex, true);
        // 将下拉列表的数据放在数据源sheet上
        HSSFRow row;
        HSSFCell cell;
        for (int i = 0, length = datas.length; i < length; i++) {
            row = hidden.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(datas[i]);
        }
        //将码值sheet页做成excel公式
        Name namedCell = wb.createName();
        namedCell.setNameName(hiddenSheetName + datas.length);
        namedCell.setRefersToFormula(hiddenSheetName + "!$A$1:$A$" + datas.length);
        //确定要在哪些单元格生成下拉框
        DVConstraint dvConstraint = DVConstraint.createFormulaListConstraint(hiddenSheetName+datas.length);
        /*CellRangeAddressList regions = new CellRangeAddressList(1 , rows , colToIndex , colToIndex);
        HSSFDataValidation dataValidation = new HSSFDataValidation(regions, dvConstraint);
        //隐藏码值sheet页
        int sheetNum = wb.getNumberOfSheets();
        for(int n=1; n<sheetNum; n++) {
            wb.setSheetHidden(n, true);
        }*/
        // 指定下拉数据时，给定目标数据范围 hiddenSheetName!$A$1:$A?   隐藏sheet的A1到A?格的数据
        //DVConstraint constraint = DVConstraint.createFormulaListConstraint(hiddenSheetName + "!$A$1:$A" + datas.length);
        // 单元格样式
        CellStyle style = workbook.createCellStyle();
        style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        if (aCol != -1) {
            CellRangeAddressList aRangeAddressList = new CellRangeAddressList(startRow, endRow, aCol, aCol);
            HSSFDataValidation aDataValidation  = new HSSFDataValidation(aRangeAddressList, dvConstraint);
            realSheet.addValidationData(aDataValidation);
        }

        if (zCol != -1) {
            CellRangeAddressList zRangeAddressList = new CellRangeAddressList(startRow, endRow, zCol, zCol);
            HSSFDataValidation zDataValidation = new HSSFDataValidation(zRangeAddressList, dvConstraint);
            realSheet.addValidationData(zDataValidation);
        }

        if (cityCal != -1) {
            CellRangeAddressList zRangeAddressList = new CellRangeAddressList(startRow, endRow, cityCal, cityCal);
            HSSFDataValidation zDataValidation = new HSSFDataValidation(zRangeAddressList, dvConstraint);
            realSheet.addValidationData(zDataValidation);
        }

        return workbook;
    }

    /**
     * @param wb HSSFWorkbook对象
     * @param realSheet 需要操作的sheet对象
     * @param datas 下拉的列表数据
     * @param startRow 开始行
     * @param endRow 结束行
     * @param startCol 开始列
     * @param endCol 结束列
     * @param hiddenSheetName 隐藏的sheet名
     * @param hiddenSheetIndex 隐藏的sheet索引
     * @return
     */
    public static HSSFWorkbook dropDownListAttrValue(Workbook wb, Sheet realSheet, String[] datas, int startRow, int endRow,
                                            int index, String hiddenSheetName, int hiddenSheetIndex) {

        HSSFWorkbook workbook = (HSSFWorkbook) wb;
        // 创建一个数据源sheet
        HSSFSheet hidden = workbook.createSheet(hiddenSheetName);
        // 数据源sheet页不显示
        workbook.setSheetHidden(hiddenSheetIndex, true);
        // 将下拉列表的数据放在数据源sheet上
        HSSFRow row;
        HSSFCell cell;
        for (int i = 0, length = datas.length; i < length; i++) {
            row = hidden.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(datas[i]);
        }
        //将码值sheet页做成excel公式
        Name namedCell = wb.createName();
        namedCell.setNameName(hiddenSheetName + datas.length);
        namedCell.setRefersToFormula(hiddenSheetName + "!$A$1:$A$" + datas.length);
        //确定要在哪些单元格生成下拉框
        DVConstraint dvConstraint = DVConstraint.createFormulaListConstraint(hiddenSheetName+datas.length);
        // 指定下拉数据时，给定目标数据范围 hiddenSheetName!$A$1:$A?   隐藏sheet的A1到A?格的数据
        //DVConstraint constraint = DVConstraint.createFormulaListConstraint(hiddenSheetName + "!$A$1:$A" + datas.length);
        // 单元格样式
        CellStyle style = workbook.createCellStyle();
        style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        CellRangeAddressList aRangeAddressList = new CellRangeAddressList(startRow, endRow, index, index);
        HSSFDataValidation aDataValidation = new HSSFDataValidation(aRangeAddressList, dvConstraint);
        realSheet.addValidationData(aDataValidation);

        return workbook;
    }
}
